<p class="Head1">Number Format Codes <help:key-word value="number format code" tag="kw65744_20" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="format code" tag="kw65744_1" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="formats; number format code" tag="kw65744_19" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="conditions; in number formats" tag="kw65744_18" xmlns:help="http://openoffice.org/2000/help"/></p>
<p class="Paragraph">The number format codes (under <help:link Id="65738" xmlns:help="http://openoffice.org/2000/help"><span class="T1">Format - Cell - Number format</span></help:link>can consist of up to three sections separated by a semicolon (;).</p>
<ul class="L1">
<li class="">
<p class="P2">If the code has two sections, the first represents positive values and zero, and the second negative values.</p>
</li>
<li class="">
<p class="P2">If a code has three sections, the first is for positive values, the second for negative values and the third for zero.</p>
</li>
</ul>
<ul class="L2">
<li class="">
<p class="P3">You can also define conditions yourself, in this case you can make the first section of hits dependent on the first condition, the second section dependent on the second condition and the third section will only be run if the first two conditions do not apply. <help:link Id="65744" Eid="einbeispiel" xmlns:help="http://openoffice.org/2000/help">An example</help:link> is found at the end of this page.</p>
</li>
</ul>
<p class="Paragraph">Use the <span class="T1">Standard</span> format to display numbers as integers and fractions as decimals. Use <span class="T1">Scientific</span> to display numbers which exceed the width of the cell.</p>
<p class="Paragraph">To display a certain number of digits (0 or #) to the left and right of the decimal separator (period), insert the separator in the number format. If the format only contains the number sign (#) to the left of the decimal separator, numbers which are less than 1 will begin with a period.</p>
<p class="Paragraph">To create placeholders for numbers, enter the following format codes in a section. If the number has more places to the right of the decimal point than there are placeholders in the format, the number will be rounded according to the number of placeholders. If the number contains more digits left of the decimal point than are placeholders in the format, the actual numbers will be displayed.</p>
<p class="Paragraph"><help:key-word value="fractions; entering" tag="kw65744_17" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="entering; fractions" tag="kw65744_16" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="numbers; entering fractions" tag="kw65744_15" xmlns:help="http://openoffice.org/2000/help"/>The number of question marks indicates how many digits can be included in the numerator and denominator in fractions. Fractions that do not fit the pattern are displayed as floating point numbers.</p>
<p class="Paragraph">To display a comma as a thousand separator or to scale a number with a factor of a thousand, insert a comma in the number format.</p>
<p class="Head2"><help:key-word value="date formats" tag="kw65744_14" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="format; date formats" tag="kw65744_13" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="numbers; date formats" tag="kw65744_12" xmlns:help="http://openoffice.org/2000/help"/>Number Format Codes for Date Formats</p>
<p class="Paragraph">To display days, months and years, insert the following format codes.</p>
<p class="Paragraph">You can adopt the following character strings into the format code if you want to use a certain calendar format. If there is no specific code entered, <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> will choose the best-possible calendar to be used.</p>
<p class="Paragraph">All calendar formats are dependent upon the "locale" setting, which you can select in <span class="T1">Tools - Options - Language settings - Languages</span>. An example: The date format code, E, EE, R or RR switches the calendar to the first non-Gregorian calendar that is entered in the current locale setting. If you use a Japanese locale setting this is the Gengou calendar. If you use a Korean locale setting this is the ROC calendar. If no other calendar is entered in the locale setting, the Gregorian calendar is used.</p>
<p class="Paragraph"><help:switch select="Program" xmlns:help="http://openoffice.org/2000/help"><help:case select="CALC">When you calculate with cell references in which at least one of the references is assigned a date or time format, the result is automatically displayed in a corresponding format. You can, however, manually assign a different format to the formula cell. You have the following options:</help:case></help:switch></p>
<p class="Paragraph"><help:switch select="Program" xmlns:help="http://openoffice.org/2000/help"><help:case select="CALC">The Date&Time format displays the date and time and is created as soon as a value in date format is added to a value in time format.</help:case></help:switch></p>
<p class="Paragraph"><help:switch select="Program" xmlns:help="http://openoffice.org/2000/help"><help:case select="CALC">Besides addition, you can also subtract, multiply or divide values. The date system for calculation with the date value of 0 is defined under <help:link Id="66267"><span class="T1">Tools - Options - Spreadsheets... - Calculate</span></help:link>. In the default setting, the date serial number 0 corresponds to 12. 30.1899.</help:case></help:switch></p>
<p class="Paragraph"><help:switch select="Program" xmlns:help="http://openoffice.org/2000/help"><help:case select="CALC">If you enter a two-digit year, the 29/30 rule will apply to determine whether it is 19xx or 20xx. For example, 1/1/10 will be calculated as the year 2010, while 1/1/30 will be calculated as 1/1/1930. When opening documents made in an earlier version than <help:productname>%PRODUCTNAME</help:productname> Calc 5.0 (in which nearly all two-digit years have the prefix 19, except the last days of 1899, see above), the old rule applies.</help:case></help:switch></p>
<p class="Head2"><help:key-word value="time formats" tag="kw65744_11" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="formats; time formats" tag="kw65744_10" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="numbers; time formats" tag="kw65744_9" xmlns:help="http://openoffice.org/2000/help"/>Number Format Codes for Time Formats</p>
<p class="Paragraph">To display hours, minutes and seconds insert the following format codes.</p>
<p class="TextInTable">You can also use the decimal point in format code to display fractions of seconds. For example, with the code hh:mm:ss,00 you show the time as 01:02:03,45.</p>
</span></th></tr></table>
<p class="Paragraph"/>
<p class="Paragraph"><help:key-word value="time format; over 24 hours" tag="kw65744_8" xmlns:help="http://openoffice.org/2000/help"/>To show a time with more than 24 hours or more than 60 minutes or seconds, place the outer left part of the code in square brackets. For example, the time code [h]:mm:ss will display more than 24 hours.</p>
<p class="Paragraph">You can calculate with time formats as you would with number formats. This is useful, for example, for subtraction such as: Duration=End time-Start time.</p>
<p class="Paragraph">If a time is entered in the form 02:03,45 or 01:02:03,45 or 25:01:02, the following formats will be assigned if no other time format is set: MM:SS,00 or [HH]:MM:SS,00 or [HH]:MM:SS. For addition and subtraction of times, the value of the cell is displayed in a format according to the result. For example, this follows the pattern =End time - Start time or =(End time - Start time)*24*Hourly rate.</p>
<p class="Paragraph">For the currency format the currency symbol that is available according to the locale setting is specified as the default, if you have selected <span class="T1">Default</span> as the language. The Euro currency can be entered with one of the following format codes:</p>
<p class="Paragraph">The EUR banking symbol is the international abbreviation for the Euro. You see the second example if you select the "Γé¼ Deutsch (Deutschland)" entry in the <span class="T1">Format</span> combo box. The [$Γé¼-407] part of the format code means that the Euro symbol (Γé¼) and the locale setting 407 are used. You select the code for a locale setting in the <span class="T1">Format</span> combo box. The code is then automatically entered correctly in the <span class="T1">Format-Code</span> field.</p>
<p class="Head2">Number Format Codes for Text and Spaces</p>
<p class="Paragraph">To display symbols, either enclose the symbol in double quotation marks or place a backslash (\) before it.</p>
<p class="Paragraph">To create a space the width of a character in the code format, insert an underscore (_) followed by this sign. By entering an underscore and a closing bracket, for example, positive numbers will be displayed flush with negative numbers in brackets.</p>
<p class="Paragraph">To include text in a number format, insert the @ sign in the format. The text entered will be formatted according to the section containing the @ sign. If the format does not contain any text, the text you enter will not be affected by the format.</p>
<p class="Head2">Other Number Format Codes</p>
<p class="Paragraph">To display numbers as percentages, (i.e., the number is multiplied by 100) add the percent sign to the number format.</p>
<p class="Head3">Scientific Format</p>
<p class="Paragraph">To display numbers in scientific format, add the following format codes to a section. If a format contains a 0 or the # sign to the right of an E-, E+, e- or e+, <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> will display the number in scientific format and adds an "E" or an "e." The number of zeros or # signs to the right determine the number of exponential places. E- or e- will show a minus sign for negative exponents. E+ or e+ will display a minus sign in negative exponents and a plus sign in positive exponents.</p>
<p class="Head3">Formats with Prefixes and Suffixes</p>
<p class="Paragraph">You can add text extensions to number formats (prefixes and suffixes) and format cells with these codes. For example, define the following format code:</p>
<p class="Paragraph">Using this code, the cell values are displayed as rounded integers, with the text enclosed in quotation marks added as a suffix (the text is displayed without quotation marks in the cell).</p>
<p class="Paragraph">In this example, by entering "1" in a cell the result will be "1 plus." Entering "-5" will produce "5 minus."</p>
<p class="Head3"><a name="einbeispiel"/><help:key-word value="number format code; with conditions" tag="kw65744_3" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="conditions; for number format codes" tag="kw65744_2" xmlns:help="http://openoffice.org/2000/help"/>Conditions in Number Formats</p>
<p class="Paragraph">You can directly include conditions as comparisons to numbers in the format code. Look at the following example:</p>
<p class="Paragraph">In this case a cell is formatted in the number format #.##0,00. If the value in the cell is smaller that or equal to 4 the text color green will be used, red will be used for a value over 7. The text color blue will be used in all other cases.</p>
<p class="Paragraph">The relational operators <, <=, >, >=, = and <> can be used in combination with any number whatsoever.</p>